<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <style>
        body {
            width: 920px;
            margin: 0 auto;
        }
        .subject {
            margin: 20px 20px;
        }
        .sname {
            font: bold 28px Arial;
        }
        a {
            color: blue;
            text-decoration: none;
        }
        .nav {
            float: right;
            margin-top: 20px;
        }
        .nav+h2 {
            clear: both;
        }
        [v-cloak] {
            display: none;
        }
    </style>
    <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
</head>
<body>
    <h2>千锋教育成都校区所有学科</h2>
    <hr>
    <div id="app" v-cloak v-loading.fullscreen.lock="loading">
        <div class="subject" v-for="subject in subjects">
            <p class="sname">
                <a :href="'/static/html/teachers.html?sno=' + subject.no">
                    {{ subject.name }}
                </a>
                <img v-if="subject.isHot" src='/static/images/hot-icon-small.png'>
            </p>
            <p>{{ subject.intro }}</p>
        </div>
    </div>
    <script src="https://unpkg.com/vue@2.6.11/dist/vue.min.js"></script>
    <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                subjects: [],
                loading: true,
            },
            created() {
                fetch('/subjects/')
                    .then(resp => resp.json())
                    .then(json => {
                        this.loading = false
                        this.subjects = json
                    })
            }
        })
    </script>
</body>
</html>